home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000094_icon-group-sender _Fri Oct 24 08:39:33 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by cheltenham.cs.arizona.edu (8.8.7/8.8.7) with SMTP id IAA26551
  4.     for <icon-group-addresses@cheltenham.CS.Arizona.EDU>; Fri, 24 Oct 1997 08:39:33 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA24456; Fri, 24 Oct 1997 08:39:32 -0700
  7. To: icon-group@cs.arizona.edu
  8. Date: Fri, 24 Oct 1997 12:58:06 +1000
  9. From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
  10. Message-Id: <Stuart.Robinson-2410971258070001@asianstmg-229.anu.edu.au>
  11. Organization: ANU
  12. Sender: icon-group-request@cs.arizona.edu
  13. References: <Stuart.Robinson-2410970146220001@asianstmg-229.anu.edu.au>
  14. Subject: Re: tabulating values
  15. Errors-To: icon-group-errors@cs.arizona.edu
  16. Status: RO
  17.  
  18. Well, I've now received six responses to my query, none of which provide a
  19. solution to the problem.  I really do appreciate the responses, but four
  20. of the responses consisted of people essentially saying "Heck, that's
  21. trivial" without proving it by actually providing a working solution and
  22. the two responses that did actually contain code failed to provide a
  23. solution.  Here they are:
  24.  
  25. PROGRAM #1
  26. ----------
  27. procedure main()
  28.  
  29. t := table(0)
  30. while t[!read()] +:= 1
  31. write("value    n")
  32. every i := !sort(t) do write(left(i[1], 9), left(i[2], 4))
  33.  
  34. end
  35.  
  36.  
  37. PROGRAM #2
  38. ----------
  39. procedure main()
  40.  
  41. count := table(0)
  42. every n := read() do 
  43. count[n] +:= 1
  44.  
  45. write("value\tn")
  46. every n := key(count) do
  47. write(n, "\t", count[n])
  48.  
  49. end
  50.  
  51.  
  52. Assume the following input (note that the last three values are two and
  53. three digit figures):
  54.  
  55.  
  56. 1
  57. 2
  58. 3
  59. 10
  60. 10
  61. 100
  62.  
  63.  
  64. The output I'd like would be something like the following:
  65.  
  66.  
  67. 1     1
  68. 2     1
  69. 3     1
  70. 10    2
  71. 100   1
  72.  
  73.  
  74. Here is what each of the above-listed programs actually outputs:
  75.  
  76.  
  77. OUTPUT OF PROGRAM #1
  78. --------------------
  79.  
  80. value    n
  81. 1        4   
  82. 2        1   
  83. 3        1 
  84.  
  85.  
  86. OUTPUT OF PROGRAM #2
  87. --------------------
  88.  
  89. value n
  90. 1  1
  91.  
  92. -- 
  93. Stuart Robinson <Stuart.Robinson@nospam.anu.edu.au>
  94. The Australian National University
  95. *TO REPLY, REMOVE "nospam." FROM E-MAIL ADDRESS GIVEN ABOVE
  96.